package hasthi.wsdm;

import static hasthi.common.constants.WSDMConstants.CAPABILITY_CONFIGURATION;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_DESCRIPTION;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_HEALTHCHECK;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_HEARTBEAT;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_MATRICS1;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_METADATA;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_OPERATIONAL_STATUS;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_OPERATIONAL_STATUS2;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_REQUEST_PROCESSING_STATUS;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_SHUTDOWN;
import static hasthi.common.constants.WSDMConstants.CAPABILITY_STATE;
import static hasthi.common.constants.WSDMConstants.MANAGMENT_EVNET_SINK_PARAM;
import hasthi.common.BaseContext;
import hasthi.common.HasthiException;
import hasthi.common.constants.WSDMConstants.SystemState;

import java.util.ArrayList;
import java.util.List;

import javax.xml.namespace.QName;

public abstract class AbstractManagedSystemHandle implements ManagedSystemHandle{
    protected final QName name;
    protected final String description;
    protected final ArrayList<String> supportedCapabilityNames = new ArrayList<String>();
    protected final ArrayList<QName> supportedConfigurationNames = new ArrayList<QName>();
    protected final ArrayList<QName> supportedMatricNames = new ArrayList<QName>();
    protected BaseContext baseContext;

    public AbstractManagedSystemHandle(QName name, String description) throws HasthiException {
        
     

        this.name = name;
        this.description = description;
      //These are default capabilities usually the agent supports, this can be edited. But users should make sure
        //corresponding capabilities are implemented
        supportedCapabilityNames.add(CAPABILITY_DESCRIPTION);
        supportedCapabilityNames.add(CAPABILITY_MATRICS1);
        supportedCapabilityNames.add(CAPABILITY_OPERATIONAL_STATUS);
        supportedCapabilityNames.add(CAPABILITY_OPERATIONAL_STATUS2);
        supportedCapabilityNames.add(CAPABILITY_REQUEST_PROCESSING_STATUS);
        supportedCapabilityNames.add(CAPABILITY_STATE);
        supportedCapabilityNames.add(CAPABILITY_HEARTBEAT);
        supportedCapabilityNames.add(CAPABILITY_CONFIGURATION);
        supportedCapabilityNames.add(CAPABILITY_METADATA);
        supportedCapabilityNames.add(CAPABILITY_SHUTDOWN);
        supportedCapabilityNames.add(CAPABILITY_HEALTHCHECK);
        
        supportedConfigurationNames.add(MANAGMENT_EVNET_SINK_PARAM);
    }
    
    public void init(ManagementAgentContext agentContext)throws HasthiException{
        baseContext = agentContext.getBaseContext();
    }

    public String getDescription() {
        return description;
    }

    public QName getResourceName() {
        return name;
    }

    public ArrayList<String> getSupportedCapabilities() {
        return supportedCapabilityNames;
    }

    public BaseContext getBaseContext() {
        return baseContext;
    }

    public List<QName> getSupportedConfigurationNames() {
        return supportedConfigurationNames;
    }

    public List<QName> getSupportedMatrics() {
        return supportedMatricNames;
    }
    
    public SystemState runResourceHealthCheck(){
        return SystemState.IdleState;
    }
    
    protected void verifySystemHandle(){
        
    }
    
}
